param=$1
# 更新源
sudo apt-get update
# 更新软件
sudo apt-get upgrade
sudo apt-get install make build-essential libssl-dev zlib1g-dev
sudo apt-get install libbz2-dev libreadline-dev libsqlite3-dev wget curl
sudo apt-get install llvm libncurses5-dev libncursesw5-dev
if [ "$param" = "pyenv" ]; then
  cd ~/pyenv && tar -xzvf pyenv.tar.gz && cd pyenv
  mkdir ~/.pyenv && cp -rpf * ~/.pyenv
  cd ~ && rm -rf pyenv
  echo 'export PYENV_ROOT="$HOME/.pyenv"' >>~/.bashrc
  echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >>~/.bashrc
  echo 'eval "$(pyenv init -)"' >>~/.bashrc
  echo 'eval "$(pyenv virtualenv-init -)"' >>~/.bashrc
  source ~/.bashrc
  #换源
  export PYTHON_BUILD_MIRROR_URL_SKIP_CHECKSUM=1
  export PYTHON_BUILD_MIRROR_URL="https://mirrors.huaweicloud.com/python/"
  eval "$(pyenv init --path)"
elif [ "$param" = "pipenv" ]; then
  pyenv install 3.8
  pyenv local 3.8
  python3 -m pip3 install --upgrade pip3
  python3 -m pip3 install --upgrade pipenv
  sudo pip3 install pipenv
  换源
  echo 'export PIPENV_TEST_INDEX=https://repo.huaweicloud.com/repository/pypi/simple' >>~/.profile
  echo 'export PATH=$PIPENV_TEST_INDEX:$PATH' >>~/.profile
  source ~/.profile
fi
#安装和设置当前目录的python环境
#换安装环境（默认路径是~/.local/share/virtualenvs）
#mkdir .venv #当前目录新建.venv
#pipenv shell 或 pipenv --python xx
